import { request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(obj: ResultType) {
  if (obj.result.resultCode == '000000') {
    return obj.data
  }
  throw new Error()
}
function adapter2(obj: ResultType) {
  if (obj.result.resultCode == '000000') {
    return obj
  }
  throw new Error()
}

/** 默认测试接口 */
export const testGet = (params?: any) =>
  request.get(`jcj-ajxx-model/queryDrJqxxTjPc`, { params }).then((res) => adapter(res as any))
/** 默认测试接口 */
export const login = (params?: any) =>
  request.post(`/user/login`,  params ).then((res) => adapter(res as any))
